<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-1-29
 * Time: 下午1:30
 * To change this template use File | Settings | File Templates.
 */
class static_reg {
    const CHS = '/^[\u0391-\uFFE5]+$/';//必须为汉字
    const MOBILE = '/^((\(\d{2,3}\))|(\d{3}\-))?(13|15|18|14)\d{9}$/';

    public static function chs($str){
        $pattern = '/^[\x{4e00}-\x{9fa5}]+$/u';
        if (!preg_match($pattern, $str)){
                return false;
        } else {
            return true;
        }
    }
    /*
     * var patternName = /^[\u4E00-\u9FA5]+$/i;
        var patternIdNum = /^[1-9]\d{14}|\d{17}$/;
        var patternPhoneNum = /^((\(\d{2,3}\))|(\d{3}\-))?(13|15|18|14)\d{9}$/;
        var patternCardNum = /^[1-9]\d{15,25}$/;
     * */
    public static function id_card($str){
        $pattern = '/^[1-9]\d{14}|\d{17}$/';
        if (!preg_match($pattern, $str)){
            return false;
        } else {
            return true;
        }
    }

    public static function mobile($str){
        $pattern = '/^((\(\d{2,3}\))|(\d{3}\-))?(13|15|18|14)\d{9}$/';
        if (!preg_match($pattern, $str)){
            return false;
        } else {
            return true;
        }
    }

    public static function bank_no($str){
        $pattern = '/^[1-9]\d{15,25}$/';
        if (!preg_match($pattern, $str)) {
            return false;
        } else {
            return true;
        }
    }

    public static function trade_no($str){
        $pattern = "/^[2][0-9A-Za-z]{27}$/";
        if (!preg_match($pattern, $str)){
            return false;
        } else {
            return true;
        }
    }

    public static function money($str){
        $pattern = "/^[0]\\.0[1-9]{1}$/";
        if (!preg_match($pattern, $str)) {
            return false;
        } else {
            return true;
        }
    }

    public static function remark($str){
        $pattern = "/^[0-9a-zA-Z]{3,10}$/";
        if (!preg_match($pattern, $str)){
            return false;
        } else {
            return true;
        }
    }

    //必须为汉字，英文，数字中的组合
    public static function real_name($str){
        $pattern = '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9]+$/u';
        if (!preg_match($pattern, $str)){
            return false;
        } else {
            return true;
        }
    }
}